import { usePlugin, MongoHandler } from "./plugin";
import { Collection } from 'mongodb'
export function useMongo<T>(handler: MongoHandler<T>) {
    return usePlugin('@sker/mongo', handler)
}
export interface MongoCollection<T> {
    (c: Collection): Promise<T>;
}
export function useMongoCollection<T>(collection: string, handler: MongoCollection<T>) {
    return usePlugin('@sker/mongo', async (db) => {
        const c = db.collection(collection)
        const res = await handler(c);
        return res;
    })
}
